#include <iostream>
using namespace std;

struct stu
{
    char name[20];
    int age;
    float score;
};

union data
{
    int a;
    long b;
    short c;
};

union sex
{
    char man;
    char woman;
};

enum color
{
    red,
    yellow,
    green
};

int main()
{
    cout << "结构体" << endl;
    struct stu s1 = {"Tom", 18, 90.5};
    cout << s1.name << " " << s1.age << " " << s1.score << endl;

    // cout << s1 << endl;  //暂时不能这样写，因为结构体没有重载<<运算符

    cout << "联合体" << endl;
    union data d1;
    d1.c = 10;
    cout << d1.a << endl;
    cout << d1.b << endl;
    cout << d1.c << endl;

    union sex s2;
    s2.man = 'M';
    cout << s2.man << " " << s2.woman << endl;

    cout << "枚举" << endl;

    color c1 = red;
    cout << c1 << endl;
    cout << red << endl;
    cout << yellow << endl;
    cout << green << endl;

    cout << "地址" << endl;
    cout << &s1 << endl;
    cout << &s1.name << endl;
    cout << &s1.age << endl;
    return 0;
}